#-*-Makefile-*- vim:syntax=make
###
 # @author Henrik Makitaavola <henrik.makitaavola@gmail.com>
 ##

SFLASH ?= /dev/ttyUSB0

TOSMAKE_PROGRAMMER_TYPE = sflash
PROGRAMMER = sflash

program: setid FORCE
	@echo -e '$(INFO_STRING) installing $(TARGET) binary using sflash'
	$(PROGRAMMER) -p $(SFLASH) $(INSTALL_SREC)

program_bl: setid FORCE
	@echo -e '$(INFO_STRING) installing $(TARGET) with bootloader using sflash'
	srec_cat $(BOOTLOADER_IMG) $(INSTALL_SREC) -exclude 0x000FFFDC 0x00100000 -o $(TOSMAKE_BUILD_DIR)/main_boot.srec -CRLF
	sed '/S5/d' $(TOSMAKE_BUILD_DIR)/main_boot.srec > $(TOSMAKE_BUILD_DIR)/main_boot2.srec
	$(PROGRAMMER) -p $(SFLASH) $(TOSMAKE_BUILD_DIR)/main_boot2.srec
	rm $(TOSMAKE_BUILD_DIR)/main_boot.srec
	rm $(TOSMAKE_BUILD_DIR)/main_boot2.srec
